package com.phkj.qdh.ui.adapter

import android.content.Context
import android.view.ViewGroup
import com.chad.library.adapter4.BaseQuickAdapter
import com.chad.library.adapter4.viewholder.QuickViewHolder
import com.phkj.qdh.R
import com.phkj.qdh.bean.DraftBean

class DraftsAdapter : BaseQuickAdapter<DraftBean, QuickViewHolder>() {
    override fun onBindViewHolder(holder: QuickViewHolder, position: Int, item: DraftBean?) {
        when (item?.type) {
            1 -> {
                val base = item.base!!
                holder.setText(R.id.tv1, "巡查类型：${base.headBean?.name}")
                holder.setText(R.id.tv2, "${base.headBean?.name}问题：${base.secondBean?.name?:""}")
                holder.setText(R.id.tv3, "处置办法：${base.eventScoreConfigurationBean?.name?:""}")
                holder.setText(R.id.tv4, "保存时间：${base.time}")
            }

            2 -> {
                val team = item.team!!
                holder.setText(R.id.tv1, "巡查类型：${team.headBean?.name}")
                holder.setText(
                    R.id.tv2, "${team.headBean?.name}问题：${team.secondType}"
                )
                holder.setText(R.id.tv3, "处置办法：${team.banfa?.name?:""}")
                holder.setText(R.id.tv4, "保存时间：${team.time}")
            }

            else -> {
                val law = item!!.law!!
                holder.setText(R.id.tv1, "巡查类型：${law.headBean?.name}")
                holder.setText(R.id.tv2, "${law.headBean?.name}问题：${law.secondType}")
                holder.setText(R.id.tv3, "处置办法：${law.banfa?.name?:""}")
                holder.setText(R.id.tv4, "保存时间：${law.time}")
            }
        }
    }

    override fun onCreateViewHolder(
        context: Context, parent: ViewGroup, viewType: Int
    ): QuickViewHolder {
        return QuickViewHolder(R.layout.item_drafts, parent)
    }
}